<?php
function displayPage()
{
	//echo secureLogIn();
	if (secureLogIn() != '1')
	{
		$formArray['varType'] = 'POST';
		$formArray['url'] = INDEX.'home'.EXT.'log='.installation();
		$formArray['addlContent'] = '';
		$formArray['element'][0] = 'text|userName||';
		$formArray['element'][1] = 'password|password||';
		$formArray['element'][2] = 'submit|button|Login|';
		if (installation() == 'create')
		{
			$formArray['element'][3] = 'text|fname||';
			$formArray['element'][4] = 'text|lname||';
			$formArray['element'][5] = 'text|email||';
			$welcome = 'There is curretly no Administrator set. Please fill in the necessary credentials to continue.';
		}
		else
		{
			$welcome = 'Enter your Username and Password to log in as administrator.<br />';
		}
	
		$login = createForm($formArray);
		$display = '<div class="container_12"><div class="grid_12 alpha"><table id="adminContain">'.$login['openTag'].'<tr><td colspan="2" id="intro">'.$welcome.'</td></tr>';
		
		if (installation() == 'create')
		{
			$display .= '<tr><td class="tdleft">First Name:</td><td class="tdright">'.$login['input']['fname'].'</td></tr>
			<tr><td class="tdleft">Last Name:</td><td class="tdright">'.$login['input']['lname'].'</td></tr>
			<tr><td class="tdleft">Email:</td><td class="tdright">'.$login['input']['email'].'</td></tr>';
		}
		
		$display .= '<tr><td class="tdleft">User Name:</td><td class="tdright">'.$login['input']['userName'].'</td></tr>
		<tr><td class="tdleft">Password:</td><td class="tdright">'.$login['input']['password'].'</td></tr>'.'<tr>
		<td colspan="2" class="tdmid">'.$login['input']['button'].'</td></tr>'.$login['closeTag'].'</table></div></div>';
		;
	}
	else
	{
		$messageDiv = staticTextDiv('adminIntro', 'Adminpage Intro');
		$userData = displayAllUsers('none', session('user'));
		
		$display = '<div class="container_12">
			<div id="intro" class="grid_12">
				<div id="adminIntroT" class="leftAlign">
					You are logged in as '.$userData['name'][0].' '.$userData['surname'][0].'
				</div>
				<div id="adminText">
					'.$messageDiv.'
				</div>
			</div>
		</div>';
	}
	return $display;
}
?>